package com.boot.web.controller;

import java.math.BigDecimal;
import java.util.Map;

import com.boot.web.dto.WeeklySplitAccountDTO;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.boot.communal.paging.InitPaging;
import com.boot.communal.response.ResponseServer;
import com.boot.web.entity.PrizePoolWeekly;
import com.boot.web.service.PrizePoolWeeklyService;

/**
 * 每周奖金池控制器
 * @author 【zhouJie】
 * @date 2021-11-02 11:54:56
 */
@RestController
@RequestMapping("/prizePoolWeekly")
public class PrizePoolWeeklyController {

    @Autowired
    private PrizePoolWeeklyService prizePoolWeeklyService;

    @PostMapping("/save")
    public ResponseServer save(PrizePoolWeekly prizePoolWeekly) {
        return ResponseServer.success("添加成功", prizePoolWeeklyService.save(prizePoolWeekly));
    }

    @PutMapping("/update")
    public ResponseServer update(PrizePoolWeekly prizePoolWeekly) {
        return ResponseServer.success("修改成功", prizePoolWeeklyService.update(prizePoolWeekly));
    }

    /**
     * 每周分账
     * @param weeklySplitAccountDTO
     * @return
     */
    @PostMapping("/weekSplitAccount")
    public ResponseServer weekSplitAccount(WeeklySplitAccountDTO weeklySplitAccountDTO) {
        Integer id = weeklySplitAccountDTO.getId();
        BigDecimal amount = weeklySplitAccountDTO.getSplitAccountAmount();


        return ResponseServer.success("分账成功");
    }

    @DeleteMapping("/delete/{id}")
    public ResponseServer delete(@PathVariable Integer id) {
        return ResponseServer.success("删除成功", prizePoolWeeklyService.delete(id));
    }

    @DeleteMapping("/batchDelete/{ids}")
    public ResponseServer batchDelete(@PathVariable Integer[] ids) {
        return ResponseServer.success("批量删除成功", prizePoolWeeklyService.batchDelete(ids));
    }

    @GetMapping("/getPageList")
    public ResponseServer getPageList(@RequestParam Map<String, Object> params) {
        InitPaging.init(params);
        return ResponseServer.success(new PageInfo(prizePoolWeeklyService.getPageList(params)));
    }

    @GetMapping("/getAll")
    public ResponseServer getAll() {
        return ResponseServer.success(prizePoolWeeklyService.getAll());
    }

    @GetMapping("/getById/{id}")
    public ResponseServer getById(@PathVariable Integer id) {
        return ResponseServer.success(prizePoolWeeklyService.getById(id));
    }

}
